package com.health.viewscontrols.tjbg.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.health.R;
import com.health.viewscontrols.tjbg.bean.TjDataBean;

import java.util.List;

/**
 * author : xiaoxin
 * date   : 2020/7/25 14:29
 * desc   :
 * update :
 */
public class TjbgDataAdapter extends BaseQuickAdapter<TjDataBean, BaseViewHolder> {


    public TjbgDataAdapter(int layoutResId, @Nullable List<TjDataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TjDataBean item) {
        helper.setText(R.id.tv_tj_data,item.getTjData())
                .setText(R.id.tv_unit,item.getTjUint())
                .setText(R.id.tv_tj_name,item.getTjType()+"");
        if (TextUtils.isEmpty(item.getTjTime())) {
            helper.setText(R.id.tv_tj_time,item.getTjTime());
        } else {
            helper.setText(R.id.tv_tj_time,TimeUtils.millis2String(TimeUtils.string2Date(item.getTjTime()).getTime(),
                    "yyyy-MM-dd HH:mm"));
        }

        ImageView iv_item_bg = helper.getView(R.id.iv_item_bg);
        iv_item_bg.setBackgroundResource(item.getTjImg());

    }
}
